﻿<!DOCTYPE html>
<!--维修作业活动-->
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="/static/js/common.js"></script>
</head>
<body>
    <div id="app" v-cloak class="popupW100">
        <el-row>
            <el-col :span="24">
                <el-form label-position="right" ref="form" :inline="true" :model="formInline" class="demo-form-inline"
                         style="margin-bottom: 15px;">
                    <el-row>
                        <el-col class="head-tool">
                            <div class="new_title fl">
                                <strong><img src="/static/images/icon1.png" />检查维修作业活动列表</strong>
                            </div>
                            <span>
                                <btn :text="col.btnSelect" imgsrc="/static/images/search.png" linetype="3"
                                     @click="onSubmit"></btn>
                                <btn :text="col.btnAdd" linetype="3" @click="UserInput('tj')"></btn>
                                <btn-template-download tempname="yh/排查标准_检维修作业活动.xlsx"></btn-template-download>
                                <btn-uploadfile-list url="/api/YH_CheckRepair/Import" @success="GetLevelOne" linetype="3"></btn-uploadfile-list>
                                <btn-export-list url="/api/YH_CheckRepair/Export" :forminline="this.formInline"   linetype="3">
                                </btn-export-list>
                                <btn :text="col.btnDelete" linetype="4" @click="onDelete"></btn>
                            </span>
                        </el-col>
                    </el-row>
                    <el-row>
                        <!--工厂组件-->
                        <list-factorys v-model="formInline.model.CreateFactory" @change="factoryChange"></list-factorys>
                        <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                            <div class="elst-select-mini">
                                <el-form-item>
                                    <el-input size="mini">
                                        <template slot="prepend">
                                            {{RisksManagement.RepairActivities.JobModule+mark.m}}
                                        </template>
                                        <el-select @visible-change="visibleChange" v-model="formInline.model.JobModule" slot="suffix"
                                                   :placeholder="RisksManagement.RepairActivities.JobModule" @change="ChangeOne">
                                            <el-option label="请选择" value=""></el-option>
                                            <el-option v-for="item in JobModule" :label="item.value" :value="item.value">
                                            </el-option>
                                        </el-select>
                                    </el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                        <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                            <div class="elst-select-mini">
                                <el-form-item>
                                    <el-input size="mini">
                                        <template slot="prepend">
                                            {{RisksManagement.RepairActivities.RepairItems+mark.m}}
                                        </template>
                                        <el-select @visible-change="visibleChange" v-model="formInline.model.RepairItems" slot="suffix"
                                                   :placeholder="RisksManagement.RepairActivities.RepairItems" @change="ChangeTwo">
                                            <el-option label="请选择" value=""></el-option>
                                            <el-option v-for="item in RepairItems" :label="item.value"
                                                       :value="item.value"></el-option>
                                        </el-select>
                                    </el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                        <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                            <div class="elst-select-mini">
                                <el-form-item>
                                    <el-input size="mini">
                                        <template slot="prepend">
                                            {{RisksManagement.RepairActivities.JobActivities+mark.m}}
                                        </template>
                                        <el-select @visible-change="visibleChange" v-model="formInline.model.JobActivities" slot="suffix"
                                                   :placeholder="RisksManagement.RepairActivities.JobActivities">
                                            <el-option label="请选择" value=""></el-option>
                                            <el-option v-for="item in JobActivities" :label="item.value"
                                                       :value="item.value"></el-option>
                                        </el-select>
                                    </el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                        <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                            <div class="elst-select-mini">
                                <el-form-item>
                                    <el-input size="mini">
                                        <template slot="prepend">
                                            {{RisksManagement.RepairActivities.RiskLevel+mark.m}}
                                        </template>
                                        <el-select @visible-change="visibleChange" v-model="formInline.model.RiskLevel" slot="suffix"
                                                   :placeholder="RisksManagement.RepairActivities.RiskLevel">
                                            <el-option label="请选择" value=""></el-option>
                                            <el-option v-for="item in RiskLevel" :label="item.value" :value="item.key">
                                            </el-option>
                                        </el-select>
                                    </el-input>
                                </el-form-item>
                            </div>
                        </el-col>

                        <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                            <div class="elst-select-mini">
                                <el-form-item>
                                    <el-input v-model="formInline.model.CheckStandard"
                                              :placeholder="RisksManagement.RepairActivities.CheckStandard" size="mini">
                                        <template slot="prepend">
                                            {{RisksManagement.RepairActivities.CheckStandard+mark.m}}
                                        </template>
                                    </el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                        <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                            <div class="elst-select-mini">
                                <el-form-item>
                                    <el-input v-model="formInline.model.RiskOfViolation"
                                              :placeholder="RisksManagement.RepairActivities.RiskOfViolation" size="mini">
                                        <template slot="prepend">
                                            {{RisksManagement.RepairActivities.RiskOfViolation+mark.m}}
                                        </template>
                                    </el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                    </el-row>
                </el-form>

                <el-row>
                    <el-col :span="4">

                        <div class="tree_lay">
                            <h4 class="title clearfix"><strong>区域</strong></h4>
                            <el-tree :data="TreeData" show-checkbox node-key="id" ref="tree" highlight-current
                                     @node-click="handleNodeClick">
                                <span slot-scope="scope">
                                    <span>
                                        <i :class="scope.data.icon"></i>
                                        <template>
                                            <span v-if="scope.data.icon == 'tree-open'"
                                                  style="color:#12489e">{{ scope.node.label }}</span>
                                            <span v-else-if="scope.data.icon == 'tree-close'"
                                                  style="color: #12489e">{{ scope.node.label }}</span>
                                            <span v-else>{{ scope.node.label }}</span>
                                        </template>
                                    </span>
                                </span>
                            </el-tree>
                        </div>
                    </el-col>
                    <el-col :span="20">
                        <el-table stripe ref="table" :data="ListItem.tableData" :height="ListItem.tableHeight" border
                                  @selection-change="handleSelectionChange" row-style="height:10px" style="width: 100%">
                            <el-table-column type="selection" align="center" width="55">
                            </el-table-column>

                            <el-table-column type="index" :label="RisksManagement.MonitorApproval.id" align="center"
                                             :index="indexMethod" width="50" show-overflow-tooltip="true"></el-table-column>
                            <el-table-column prop="jobModule" show-overflow-tooltip="true" align="center"
                                             width="110" :label="RisksManagement.RepairActivities.JobModule">
                            </el-table-column>
                            <el-table-column prop="repairItems" show-overflow-tooltip="true" align="center"
                                             width="110" :label="RisksManagement.RepairActivities.RepairItems">
                            </el-table-column>
                            <el-table-column prop="jobActivities" show-overflow-tooltip="true"
                                             width="90" :label="RisksManagement.RepairActivities.JobActivities">
                            </el-table-column>
                            <el-table-column prop="checkStandard" show-overflow-tooltip="true"
                                             :label="RisksManagement.RepairActivities.CheckStandard">
                            </el-table-column>
                            <el-table-column prop="riskOfViolation" show-overflow-tooltip="true"
                                             :label="RisksManagement.RepairActivities.RiskOfViolation">
                            </el-table-column>
                            <el-table-column prop="riskLevelText" show-overflow-tooltip="true" align="center"
                                             width="90" :label="RisksManagement.RepairActivities.RiskLevel">
                            </el-table-column>
                            <el-table-column width="53" prop="update" :label="col.btnUpdate" fixed="right">
                                <template slot-scope="scope">
                                    <button type="button" class="elst-bt-xg" @click=UserInput('xg',scope.row.id)>
                                        <i class="el-icon-edit"></i>
                                    </button>
                                </template>
                            </el-table-column>
                        </el-table>
                        <el-row type="flex" justify="end">


                            <el-pagination ref="page" @size-change="handleSizeChange"
                                           @current-change="handleCurrentChange" :current-page="ListItem.currentPage"
                                           :page-sizes="ListItem.pagesizes" :page-size="ListItem.pagesize"
                                           :layout="ListItem.layout" :total="ListItem.total">
                            </el-pagination>

                        </el-row>
                    </el-col>
                </el-row>


            </el-col>
        </el-row>
        <el-dialog title="维修作业活动管理" fullscreen="true" :visible.sync="ListItem.dialogVisible" @close='closeDialog' width="80%" height="80%"
                   top="10vh">
            <iframe ref="iframe" :src="ListItem.InputUrl" style="height:95%;width:100%" frameborder="0"></iframe>
        </el-dialog>

        <delete-select v-model="deleteSelectVisible"
                       :app="this"
                       delete-muti="/api/YH_CheckRepair/DeleteMuti"
                       count-url="/api/YH_CheckRepair/SelectCount"
                       delete-query-result-url="/api/YH_CheckRepair/DeleteSelect">
        </delete-select>
    </div>
    <script type="text/javascript">
        app = new Vue({
            el: '#app',
            data: function () {
                return {
                    deleteSelectVisible: false,
                    pageInitial: null,
                    //页面内左树
                    TreeData: [],
                    defaultProps: {
                        children: 'children',
                        label: 'label'
                    },
                    JobModule: [],
                    RepairItems: [],
                    JobActivities: [],
                    RiskLevel: [],
                    TreeNode: [],
                    //页面内数据初始化
                    ListItem: ListItem,
                    formInline: {
                        model: {
                            CreateFactory: null,
                            JobModule: '',
                            RepairItems: '',
                            JobActivities: '',
                            RiskLevel: '',
                            CheckStandard: '',
                            RiskOfViolation: '',
                            areaId: '',
                            AreaIds: []
                        },
                        offset: 0,
                        limit: 10
                    }
                }
            },
            mounted: function () {
                tablehigh(this);
                //获取下拉菜单内容
                this.pageInitial = PageInitial(["03"], []);//隐患等级
                var dicDataList = this.pageInitial.dataDicList;
                //隐患等级
                this.RiskLevel = getDicDataFodDataList(dicDataList, '03');
            },
            methods: {
                //解決edge下select bug
                visibleChange: function (isVisible) {
                    visibleChange(isVisible)
                },
                //加载一级下拉
                GetLevelOne: function () {
                    var mythis = this;
                    var factory = this.formInline.model.CreateFactory;
                    myAjax("get", this, '/api/YHDropDown/CheckRepairJobModule/' + factory, null, function (response) {
                        var ajaxModel = response.data;
                        mythis.JobModule = ajaxModel;
                    }, false);
                },
                //一级下拉改变事件，联动二级
                ChangeOne: function () {
                    var mythis = this;
                    var factory = this.formInline.model.CreateFactory;
                    var url = '/api/YHDropDown/CheckRepairRepairItems/' + this.formInline.model.JobModule + "/" + factory
                    myAjax("get", this, url, null, function (response) {
                        var ajaxModel = response.data;
                        mythis.RepairItems = ajaxModel;

                    }, false);
                    //mythis.formInline.model.MainCate = '';
                    //mythis.formInline.model.MainProjects = '';
                },
                //二级下拉改变事件，联动三级
                ChangeTwo: function () {
                    var mythis = this;
                    var factory = this.formInline.model.CreateFactory;
                    var url = '/api/YHDropDown/CheckRepairJobActivities/' + this.formInline.model.RepairItems + '/' + factory
                    myAjax("get", this, url, null, function (response) {
                        var ajaxModel = response.data;
                        mythis.JobActivities = ajaxModel;
                    }, false);
                    //mythis.formInline.model.MainProjects = '';
                },
                //表格序号连续化
                indexMethod: function (index) {
                    return (this.ListItem.currentPage - 1) * this.ListItem.pagesize + index + 1;
                },
                handleNodeClick: function (data) {
                    if (!data.children) {

                        this.$refs.tree.setCheckedKeys([]);
                        this.$refs.tree.setCheckedKeys([data.id]);
                    } else {
                        this.$refs.tree.setCheckedKeys([]);
                        this.$refs.tree.setCheckedKeys([data.id]);
                        if (data.icon == "tree-open") {
                            data.icon = "tree-close"
                        } else (
                            data.icon = "tree-open"
                        )
                    }
                    this.formInline.model.AreaIds = this.$refs.tree.getCheckedKeys()
                    onSubmit(this);
                },
                closeDialog: function () { closeDialog(this); },
                //删除方法
                onDelete: function () {
                    this.deleteSelectVisible = true;
                },
                //列表选择触发
                handleSelectionChange: function (val) { handleSelectionChange(this, val); },
                //Dialog展示
                UserInput: function (val, id) { DialogShow(this, val, "RepairActivitiesInput.html", id); },
                factoryChange: function () {
                    this.TreeData = GetAreaTreeData(this, this.formInline.model.CreateFactory);
                    //绑定JobSteps
                    this.GetLevelOne();
                    this.GetPageData(1);
                },
                //获取分页数据
                GetPageData: function (currentIndex) {
                    //注意：后台约束空值为null  但是Tree id =null时有bug体现在setCheckedKeys 所以只能在扁平化上处理为guidempty，在传给后台前设置为空数组
                    if (this.formInline.model.AreaIds.length == 1 && this.formInline.model.AreaIds[0] == guidEmpty)
                        this.formInline.model.AreaIds = []
                    GetPageData(this, currentIndex, '/api/YH_CheckRepair/GetList')
                },
                //查询方法
                onSubmit: function () { onSubmit(this); },
                //pagesize改变 触发方法
                handleSizeChange: function (val) { handleSizeChange(this, val); },
                //跳页触发方法
                handleCurrentChange: function (val) { handleCurrentChange(this, val); },
            }
        });

    </script>
</body>

</html>